package com.eam.handler;

import com.eam.data.EamMaintainItem;
import com.eam.data.EamRepairItem;
import com.mes.data.EmesProcessOpr;
import org.codehaus.jettison.json.JSONObject;
import org.openbravo.client.kernel.BaseActionHandler;
import org.openbravo.dal.service.OBDal;
import java.util.Map;

/**
 * 设备维修
 */
public class FacilityMaintainInFoHandler extends BaseActionHandler {
	@Override
	protected JSONObject execute(Map<String, Object> parameters, String data) {

		JSONObject jsonRep = new JSONObject();
		try {
			JSONObject reqData = new JSONObject(data);
			String id = reqData.getString("MaintainID");
			String type = reqData.getString("type");
			// 获取生产数据
			if(type.equalsIgnoreCase("emesRepair")){
				EamRepairItem  er = OBDal.getInstance().get(EamRepairItem.class, id);
				jsonRep.put("name", er.getName());
				jsonRep.put("details", er.getDetails());
				jsonRep.put("standard", er.getStandard());	
				jsonRep.put("type", "repair");
			}else if(type.equalsIgnoreCase("emesProcessOpr")){
				EmesProcessOpr ero = OBDal.getInstance().get(EmesProcessOpr.class, id);
				jsonRep.put("name", ero.getName());
				jsonRep.put("type", "emesroute");
			}else{
				EamMaintainItem  em = OBDal.getInstance().get(EamMaintainItem.class, id);
				jsonRep.put("name", em.getName());
				jsonRep.put("details", em.getDetails());
				jsonRep.put("standard", em.getStandard());
				jsonRep.put("type", "maintain");
			}
			
			// 物料名称
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jsonRep;
	}
}
